import global_var
import os

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMainWindow,QMenuBar,QAction

import ctypes

import platform


class Ui_StartWindow(QMainWindow):

    def _createMenuBar(self):
        menuBar = QMenuBar(self)
        self.setMenuBar(menuBar)

        inputMenu = menuBar.addMenu("&文件")
        self.SelectFile_Action = QAction("&选择文件", self)
        inputMenu.addAction(self.SelectFile_Action)
        
        # modelMenu = menuBar.addMenu("&模型")
        # self.PhotovoltaicModel_Action = QAction("&光伏模型", self)
        # modelMenu.addAction(self.PhotovoltaicModel_Action)
        # self.WindPowerModel_Action = QAction("&风电模型", self)
        # modelMenu.addAction(self.WindPowerModel_Action)

        # gridMenu = menuBar.addMenu("&网架结构")
        # self.TransmissionNetwork_Action = QAction("&输电网", self)
        # gridMenu.addAction(self.TransmissionNetwork_Action)
        # self.DistributionNetwork_Action = QAction("&配电网", self)
        # gridMenu.addAction(self.DistributionNetwork_Action)

        calculateMenu = menuBar.addMenu("&评估")
        self.StandardCalculation_Action = QAction("&标准方法", self)
        calculateMenu.addAction(self.StandardCalculation_Action)

        helpMenu = menuBar.addMenu("&帮助")
        self.FileFormat_Action = QAction("&输入文件格式要求", self)
        helpMenu.addAction(self.FileFormat_Action)
        self.Tip_Action = QAction("&贴士", self)
        helpMenu.addAction(self.Tip_Action)
        helpMenu.addSeparator()
        self.ServiceManual_Menu = helpMenu.addMenu("&使用手册")
        self.WinServiceManual_Action = QAction("&Window系统使用手册",self)
        self.ServiceManual_Menu.addAction(self.WinServiceManual_Action)
        self.iOSServiceManual_Action = QAction("&iOS系统使用手册",self)
        self.ServiceManual_Menu.addAction(self.iOSServiceManual_Action)
        helpMenu.addSeparator()
        self.About_Action = QAction("&关于",self)
        helpMenu.addAction(self.About_Action)
        self.Acknowledge_Action = QAction("&鸣谢",self)
        helpMenu.addAction(self.Acknowledge_Action)

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.setWindowModality(QtCore.Qt.NonModal)
        MainWindow.resize(981, 650)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
        MainWindow.setSizePolicy(sizePolicy)
        MainWindow.setMinimumSize(QtCore.QSize(981, 650))
        MainWindow.setMaximumSize(QtCore.QSize(981, 650))
        MainWindow.setMouseTracking(False)

        MainWindow._createMenuBar()

        MainWindow.setStyleSheet("QMainWIndow#MainWindow{\n"
                                "border-width: 10px;\n"
                                "border-radius: 100px;\n"
                                "}\n"
                                "QStackedWidget#stackedWidget{\n"
                                "border-bottom-right-radius: 10px;\n"
                                "}\n"
                                "\n"
                                "QWidget#centralwidget{\n"
                                "background-color: rgba(0, 50, 128, 140);\n"
                                "color: white;\n"
                                "font-size:27px;\n"
                                "font-family: 微软雅黑;\n"
                                "}\n"
                                "QFrame#frame{\n"
                                "background-color: rgb(238, 245, 249);\n"
                                "border-radius: 10px;\n"
                                "\n"
                                "}\n"
                                "QWidget#navigation{            /*navigation bar*/\n"
                                "background-color:rgba(53, 37, 138, 186);\n"
                                "border-bottom-left-radius: 10px;\n"
                                "}\n"
                                "QWidget#widget_2{        /*icon bar*/\n"
                                "background-color:rgba(53, 37, 138, 130);\n"
                                "border-top-left-radius: 10px;\n"
                                "}\n"
                                "\n"
                                "QWidget#widget_15{        /*放search bar*/\n"
                                "background-color:rgb(229, 232, 233)\n"
                                "}\n"
                                "\n"
                                "QWidget#widget_17{        /*放两个小圆按钮*/\n"
                                "background-color:rgb(229, 232, 233);\n"
                                "border-top-right-radius: 10px;\n"
                                "}\n"
                                "\n"
                                "QLabel#label_3,#label_4,#label_5{     /*GUI Chart*//*V 1.0.0*/\n"
                                "background-color:rgba(250, 249, 251, 60);\n"
                                "color:white;\n"
                                "font-size:22px;\n"
                                "border-radius:10px;\n"
                                "font-family: 微软雅黑;\n"
                                "}\n"
                                "\n"
                                "QComboBox#comboBox_2,#comboBox_3{     /*GUI Chart*//*V 1.0.0*/\n"
                                "background-color:rgba(250, 249, 251, 60);\n"
                                "color:white;\n"
                                "font-size:22px;\n"
                                "border-radius:10px;\n"
                                "font-family: 微软雅黑;\n"
                                "}\n"
                                "\n"
                                "QLabel#label_8{     /*每一页icon*/\n"
                                "color:rgb(117, 117, 117);\n"
                                "font-size:18px;\n"
                                "font: bold \"Times New Roman\";\n"
                                "}\n"
                                "\n"
                                "QLabel#label_14,#label_15{     /*made by,  designed by*/\n"
                                "color:blue;\n"
                                "font-family:微软雅黑;\n"
                                "}\n"
                                "\n"
                                "QLabel#label_16,#label_17{     /*made by,  designed by*/\n"
                                "color:white;\n"
                                "font-family:微软雅黑;\n"
                                "}\n"
                                "\n"
                                "\n"
                                "QLineEdit#lineEdit_4{     /*search bar*/\n"
                                "color:rgba(100, 88, 117,250);\n"
                                "font-size:15px;\n"
                                "font: bold \"Times New Roman\";\n"
                                "border-width: 2px;\n"
                                "border-radius: 16px;\n"
                                "}\n"
                                "\n"
                                "\n"
                                "QPushButton#pushButton_16{  /*search button*/\n"
                                "background-color:rgba(30, 249, 251, 50);\n"
                                "color:white;\n"
                                "font-size:16px;\n"
                                "border-width: 2px;\n"
                                "border-radius: 16px;\n"
                                "font-family: 微软雅黑;\n"
                                "}\n"
                                "QPushButton#pushButton_16:hover{\n"
                                "background:rgba(30, 249, 251, 100);\n"
                                "}\n"
                                "QPushButton#pushButton_16:pressed{\n"
                                "background:rgba(30, 230, 230, 150);\n"
                                "border: 1px solid #3C3C3C!important;\n"
                                "}\n"
                                "\n"
                                "\n"
                                "QPushButton#pushButton_12{  /*hamburger*/\n"
                                "background-color: transparent;\n"
                                "}\n"
                                "\n"
                                "QPushButton#pushButton_13{\n"
                                "background-color:rgba(138, 128, 200,100);\n"
                                "color:white;\n"
                                "font-size:16px;\n"
                                "font-family: 微软雅黑;\n"
                                "}\n"
                                "\n"
                                "QPushButton#pushButton_13,#pushButton_15{        /*选择文件*/\n"
                                "background-color:rgba(250, 249, 251, 60);\n"
                                "color:white;\n"
                                "font-size:22px;\n"
                                "border-radius:10px;\n"
                                "font-family: 微软雅黑;\n"
                                "}\n"
                                "\n"
                                "QPushButton#pushButton_13:hover,#pushButton_15:hover{        /*sign out*/\n"
                                "background:rgba(250, 249, 251, 100);\n"
                                "}\n"
                                "\n"
                                "QPushButton#pushButton_13:pressed,#pushButton_15:pressed{    \n"
                                "background:rgba(230, 230, 230, 150);\n"
                                "}\n"
                                "\n"
                                "QPushButton#pushButton_2,#pushButton_3,#pushButton_4,#pushButton_5,#pushButton_6{  /*dashboard buttons*/\n"
                                "background-color:rgba(250, 249, 251, 60);\n"
                                "color:white;\n"
                                "font-size:16px;\n"
                                "border-width: 2px;\n"
                                "border-radius: 16px;\n"
                                "font-family: 微软雅黑;\n"
                                "}\n"
                                "QPushButton#pushButton_2:hover,#pushButton_3:hover,#pushButton_4:hover,#pushButton_5:hover,#pushButton_6:hover{/*鼠标移到dashboard 按钮*/\n"
                                "background:rgba(250, 249, 251, 100);\n"
                                "}\n"
                                "QPushButton#pushButton_2:pressed,#pushButton_3:pressed,#pushButton_4:pressed,#pushButton_5:pressed,#pushButton_6:pressed{        /*dashboard 按钮按下*/\n"
                                "background:rgba(230, 230, 230, 150);\n"
                                "border: 1px solid #3C3C3C!important;\n"
                                "}\n"
                                "\n"
                                "QPushButton#pushButton_2:open,#pushButton_3:open,#pushButton_4:open,#pushButton_5:open,#pushButton_6:open{        /*dashboard 按钮选中*/\n"
                                "background:rgba(230, 230, 230, 175);\n"
                                "border: 1px solid #3C3C3C!important;\n"
                                "}\n"
                                "\n"
                                "/*缩小按钮*/\n"
                                "QPushButton#pushButton_10,#pushButton_11,#pushButton_7,#pushButton_8,#pushButton_9{  /*dashboard buttons*/\n"
                                "background-color:rgba(250, 249, 251, 60);\n"
                                "color:white;\n"
                                "font-size:16px;\n"
                                "border-width: 4px;\n"
                                "border-radius: 16px;\n"
                                "font-family: 微软雅黑;\n"
                                "}\n"
                                "QPushButton#pushButton_10:hover,#pushButton_11:hover,#pushButton_7:hover,#pushButton_8:hover,#pushButton_9:hover{/*鼠标移到dashboard 按钮*/\n"
                                "background:rgba(250, 249, 251, 100);\n"
                                "}\n"
                                "QPushButton#pushButton_10:pressed,#pushButton_11:pressed,#pushButton_7:pressed,#pushButton_8:pressed,#pushButton_9:pressed{        /*dashboard 按钮按下*/\n"
                                "background:rgba(230, 230, 230, 150);\n"
                                "border: 1px solid #3C3C3C!important;\n"
                                "}\n"
                                "\n"
                                "QPushButton#pushButton_10:open,#pushButton_11:open,#pushButton_7:open,#pushButton_8:open,#pushButton_9:open{        /*dashboard 按钮选中*/\n"
                                "background:rgba(230, 230, 230, 175);\n"
                                "border: 1px solid #3C3C3C!important;\n"
                                "}\n"
                                "/*缩小按钮*/\n"
                                "\n"
                                "QWidget#widget_3,#widget_4,#widget_5,#widget_6{\n"
                                "background:white\n"
                                "}\n"
                                "\n"
                                "QWidget#widget_10,#widget_7,#widget_8,#widget_9{ /*menu page*/\n"
                                "background:white\n"
                                "}\n"
                                "\n"
                                "QWidget#widget_11,#widget_12,#widget_13,#widget_14{ /*chart page*/\n"
                                "background:white\n"
                                "}\n"
                                "\n"
                                "QWidget#page,#page_2,#page_3,#page_4{            /*每一页page*/\n"
                                "background:rgb(229, 232, 233)\n"
                                "}\n"
                                "\n"
                                "QPushButton#pushButton_14{        /*退出按钮*/\n"
                                "background:#CE0000;\n"
                                "color:white;\n"
                                "font-size:16px;\n"
                                "border-radius: 8px;\n"
                                "font-family: 微软雅黑;\n"
                                "}\n"
                                "QPushButton#pushButton_14:hover{                 \n"
                                "background:#FF2D2D;\n"
                                "}\n"
                                "QPushButton#pushButton_14:pressed{\n"
                                "border: 1px solid #3C3C3C!important;\n"
                                "background:#AE0000;\n"
                                "}\n"
                                "\n"
                                "QPushButton#pushButton{    /*最小化按钮*/\n"
                                "background:rgba(108, 108, 108,160);\n"
                                "color:white;\n"
                                "font-size:16px;border-radius: 8px;font-family: 微软雅黑;\n"
                                "}\n"
                                "QPushButton#pushButton:hover{                 \n"
                                "background:#9D9D9D;\n"
                                "}\n"
                                "QPushButton#pushButton:pressed{\n"
                                "border: 1px solid #3C3C3C!important;\n"
                                "}")
        MainWindow.setAnimated(True)
        MainWindow.setDocumentMode(False)
        MainWindow.setDockNestingEnabled(False)
        
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setContextMenuPolicy(QtCore.Qt.PreventContextMenu)
        self.centralwidget.setObjectName("centralwidget")
        
        self.widget = QtWidgets.QWidget(self.centralwidget)
        self.widget.setGeometry(QtCore.QRect(0, -1, 981, 661))
        self.widget.setObjectName("widget")
        
        self.label = QtWidgets.QLabel(self.widget)
        self.label.setGeometry(QtCore.QRect(140, 120, 711, 171))
        self.label.setStyleSheet("color: white;\n"
                                 "font-size:35px;\n"
                                 "font-family: 微软雅黑;\n")
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setObjectName("label")

        self.comboBox_2 = QtWidgets.QComboBox(self.centralwidget)
        self.comboBox_2.setGeometry(QtCore.QRect(350, 400, 280, 40))
        self.comboBox_2.setObjectName("comboBox_2")
        self.comboBox_2.addItem("")
        self.comboBox_2.addItem("")
        self.comboBox_2.addItem("")
        self.comboBox_2.setCurrentIndex(0)
        self.comboBox_3 = QtWidgets.QComboBox(self.centralwidget)
        self.comboBox_3.setGeometry(QtCore.QRect(350, 460, 280, 40))
        self.comboBox_3.setObjectName("comboBox_3")
        self.comboBox_3.addItem("")
        self.comboBox_3.addItem("")
        self.comboBox_3.addItem("")
        self.comboBox_3.setCurrentIndex(0)
        
        self.label_3 = QtWidgets.QLabel(self.widget)
        self.label_3.setGeometry(QtCore.QRect(350, 340, 280, 40))
        self.label_3.setAlignment(QtCore.Qt.AlignCenter)
        self.label_3.setObjectName("label_3")
        # self.label_4 = QtWidgets.QLabel(self.widget)
        # self.label_4.setGeometry(QtCore.QRect(350, 400, 280, 40))
        # self.label_4.setAlignment(QtCore.Qt.AlignCenter)
        # self.label_4.setObjectName("label_4")
        # self.label_5 = QtWidgets.QLabel(self.widget)
        # self.label_5.setGeometry(QtCore.QRect(350, 460, 280, 40))
        # self.label_5.setAlignment(QtCore.Qt.AlignCenter)
        # self.label_5.setObjectName("label_5")

        MainWindow.setCentralWidget(self.centralwidget)
        self.actionchar1 = QtWidgets.QAction(MainWindow)
        self.actionchar1.setObjectName("actionchar1")
        self.retranslateUi(MainWindow)

        mysystem = platform.system()
        if mysystem == 'Windows':
            ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("myappid") #更改应用的DLL
        elif mysystem == 'Darwin':
            pass
        icon = QtGui.QIcon() #创建图标对象
        icon.addPixmap(QtGui.QPixmap(global_var.get_value('direction') + "pic" + os.sep + 'icon.ico'),QtGui.QIcon.Normal, QtGui.QIcon.Off) #把图标文件添加到图标对象中
        MainWindow.setWindowIcon(icon)


    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label.setText(_translate("MainWindow", "欢迎使用分布式新能源承载力评估软件"))
        self.label_3.setText(_translate("MainWindow", "未选择文件"))
        # self.label_4.setText(_translate("MainWindow", "未选择模型"))
        # self.label_5.setText(_translate("MainWindow", "未选择网架结构"))
        self.comboBox_2.setItemText(0, _translate("MainWindow", "未选择模型"))
        self.comboBox_2.setItemText(1, _translate("MainWindow", "光伏模型"))
        self.comboBox_2.setItemText(2, _translate("MainWindow", "风电模型"))
        self.comboBox_3.setItemText(0, _translate("MainWindow", "未选择网架结构"))
        self.comboBox_3.setItemText(1, _translate("MainWindow", "输电网"))
        self.comboBox_3.setItemText(2, _translate("MainWindow", "配电网"))
        self.actionchar1.setText(_translate("MainWindow", "Github"))



